package listbyorder.access201_300.test300;

import java.util.Arrays;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/28 16:46
 */
public class Solution1 {

    // 动态规划求解
    public int lengthOfLIS(int[] nums) {
        if (nums.length < 2) return nums.length;
        int n = nums.length;
        int ans = 1;
        int[] dp = new int[n];
        Arrays.fill(dp, 1);
        for (int i = n - 2; i >= 0; i--) {
            for (int j = n - 1; j > i; j--) {
                if (nums[i] < nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
            ans = Math.max(ans, dp[i]);
        }
        return ans;
    }
}
